package cn.bisoft.java.test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamInclude;
import com.thoughtworks.xstream.annotations.XStreamOmitField;

@SuppressWarnings("unused")
@XStreamAlias("body")
public class ExampleMessageBody
{
	@XStreamAsAttribute
	private static final String type = "example";
	
	private String id = "message id";

	private Date timestamp;
	
	/** 当userList节点必须存在是, 需要初始化. 值为空的字段是不会输出到XML的. */
	@XStreamAlias("users")
	private List<User> userList = new ArrayList<User>();
	
	@XStreamAlias("user")
	public static class User
	{
		@XStreamAsAttribute
		private String id;

		@XStreamAsAttribute
		private Date birth;
		
		@XStreamOmitField
		private String password;

		public String getId()
		{
			return id;
		}

		public void setId(String id)
		{
			this.id = id;
		}

		public Date getBirth()
		{
			return birth;
		}

		public void setBirth(Date birth)
		{
			this.birth = birth;
		}

		public String getPassword()
		{
			return password;
		}

		public void setPassword(String password)
		{
			this.password = password;
		}
		
	}

	
	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public Date getTimestamp()
	{
		return timestamp;
	}

	public void setTimestamp(Date timestamp)
	{
		this.timestamp = timestamp;
	}

	public List<User> getUserList()
	{
		return userList;
	}

	public void setUserList(List<User> userList)
	{
		this.userList = userList;
	}

}
